package com.puhui.lib.base.mvp

import android.app.Activity
import android.content.Context
import androidx.annotation.ColorRes
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import com.blankj.utilcode.util.ActivityUtils
import com.puhui.lib.utils.LogUtils

interface IView {

    fun startLoading(text: String? = "加载中")

    fun stopLoading()

    fun showToast(message: String? = null)

    fun showToast(@StringRes resourceId: Int)

    fun startActivity(clazz: Class<*>)

    fun startActivityForResult(clazz: Class<*>, requestCode: Int)

    fun getTopActivity(): Activity = ActivityUtils.getTopActivity()

    fun getTopContext(): Context = ActivityUtils.getTopActivity()

    fun isAvailable(): Boolean

    fun getResColor(@ColorRes colorRes: Int): Int =
        ContextCompat.getColor(getTopContext(), colorRes)

    fun getResString(@StringRes stringRes: Int): String {
        return getTopContext().getString(stringRes)
    }

    fun printLog(logMsg: String) {
        LogUtils.printE(logMsg)
    }

    fun onNetworkError() {}
}